<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>页面尺寸事件</title>
    <style>
        .box {
            width: 200px;
            height: 200px;
            padding: 5px;
            margin: 5px;
            border: 3px solid red;
            background:palegreen;
        }
    </style>
</head>
<body>
    <div class="box"></div>

    <script>
        // 1. 页面尺寸事件
        window.addEventListener('resize',function(){
            console.log('页面尺寸变了')
        })

        // 2. 元素的宽度
        const box = document.querySelector('.box')
        console.log(box.clientWidth)
        console.log(box.clientHeight)
        
        console.log(document.documentElement.clientWidth)
        console.log(document.documentElement.clientHeight)
        
        
    </script>
</body>
</html>